﻿<MudPopoverProvider />

<MudGrid>
    <MudItem xs="12" md="12">
        <MudSelect T="string" Label="Felines" HelperText="Pick your favorite feline"
                   MultiSelection="true" SelectAll="true" SelectAllText="Select all felines"
                   @bind-Value="_value" @bind-SelectedValues="_options" AdornmentIcon="@Icons.Material.Filled.Search"
                   MultiSelectionTextFunc="@(new Func<List<string>, string>(GetMultiSelectionText))">
            @foreach (var feline in felines)
            {
                <MudSelectItem T="string" Value="@feline">@feline</MudSelectItem>
            }
        </MudSelect>
    </MudItem>
    <MudItem xs="12" md="6">
        <MudText Typo="Typo.body2">MudSelect.Value: "@_value"</MudText>
    </MudItem>
</MudGrid>

@code {
    private string _value  = "Nothing selected";
    private IEnumerable<string> _options = [];

    private readonly string[] felines =
    [
        "Jaguar", "Leopard", "Lion", "Lynx", "Panther", "Puma", "Tiger"
    ];

    private static string GetMultiSelectionText(List<string> selectedValues)
    {
        return $"{selectedValues.Count} feline{(selectedValues.Count > 1 ? "s have" : " has")} been selected";
    }
}
